package com.APIObject.String_;

import java.util.StringJoiner;

public class StringJoiner_ {
    public static void main(String[] args) {
        // StringJoiner s=new StringJoiner(",");//间隔符
        StringJoiner s = new StringJoiner(",", "[", "]");//间隔符
        s.add("java1");
        s.add("java2");
        s.add("java3");
        s.add("java4");
        System.out.println(s);
        System.out.println(getArrayData(new int[]{11, 22, 33}));
    }
    public static String getArrayData(int[]arr){
        if(arr==null){
            return null;
        }
        StringJoiner s=new StringJoiner(",","[","]");
        for (int i = 0; i <arr.length ; i++) {
            s.add(arr[i]+"");//拼接时只能拼接字符串
        }


         return s.toString();
    }
}
